<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateProductsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('products', function (Blueprint $table) {
            $table->id()->comment('商品表');
            $table->integer('mer_id')->index()->default(0)->comment('商户Id(0为总后台管理员创建,不为0的时候是商户后台创建)');
            $table->integer('system_admin_id')->index()->comment('总后台管理员id');
            $table->string('temp_id')->index()->comment('运费模板id');
            $table->string('product_name')->comment('商品名称');
            $table->string('keyword')->index()->nullable()->comment('关键字');
            $table->integer('sort')->default(0)->comment('排序');
            $table->string('image')->comment('商品封面图片');
            $table->string('recommend_image')->nullable()->comment('推荐图');
            $table->json('slider_image')->comment('轮播图');
            $table->string('product_info')->nullable()->comment('商品简介');
            $table->string('unit_name')->comment('单位名');
            $table->decimal('give_integral',8,2)->default(0)->comment('赠送积分');
            $table->integer('ficti')->default(0)->comment('虚拟销量');
            $table->integer('stock')->default(0)->comment('商品库存');
            $table->string('code_path')->nullable()->comment('商品二维码地址(用户小程序海报)');
            $table->string('soure_link')->nullable()->comment('淘宝京东1688类型');
            $table->string('video_link')->nullable()->comment('主图视频');
            $table->string('spu')->index()->comment('商品SPU');
            $table->string('command_word')->index()->nullable()->comment('复制口令');
            $table->tinyInteger('status')->default(1)->comment('商品状态（0：下架，1：上架）');
            $table->tinyInteger('is_hot')->default(0)->comment('是否热卖 0 = 否 1 = 是');
            $table->tinyInteger('is_benefit')->default(0)->comment('是否促销 0 = 否 1 = 是');
            $table->tinyInteger('is_best')->default(0)->comment('是否精品 0 = 否 1 = 是');
            $table->tinyInteger('is_new')->default(0)->comment('是否新品 0 = 否 1 = 是');
            $table->tinyInteger('mer_use')->default(0)->comment('商户是否代理 0不可代理1可代理');
            $table->tinyInteger('is_seckill')->default(0)->comment('秒杀状态 0 未开启 1已开启');
            $table->tinyInteger('is_bargain')->default(0)->comment('砍价状态 0未开启 1开启');
            $table->tinyInteger('is_pink')->default(0)->comment('拼团状态 0未开启 1开启');
            $table->tinyInteger('is_good')->default(0)->comment('是否优品推荐 0 = 否 1 = 是');
            $table->tinyInteger('is_sub')->default(0)->comment('是否单独分佣 0 = 否 1 = 是');
            $table->tinyInteger('is_vip')->default(0)->comment('是否开启会员价格 0 = 否 1 = 是');
            $table->tinyInteger('spec_type')->nullable()->comment('规格 0单 1多');
            $table->string('activity')->default('0,1,2,3')->comment('活动显示排序0=默认，1=秒杀，2=砍价，3=拼团');
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('products');
    }
}
